-- Decompiled with the Synapse X Luau decompiler.

local l__CommonOHOH__1 = _G.CommonOHOH;
local v2 = l__CommonOHOH__1.load.OHOHConnection();
local v3 = l__CommonOHOH__1.class.new(script);
function v3.ctor(p1)
	p1.co_list = {};
	p1.wait_list = {};
end;
function v3.dtor(p2)
	p2.co_list = {};
	p2.context_marks = {};
end;
function v3.new()
	return v3();
end;
local l__assert__1 = assert;
local u2 = l__CommonOHOH__1.load.ObjectManager();
local l__warn__3 = warn;
local l__debug__4 = debug;
local l__coroutine__5 = coroutine;
local l__os__6 = os;
local l__xpcall__7 = xpcall;
local l__table__8 = table;
function v3.AddUpdate(p3, p4, p5, p6, ...)
	l__assert__1(p4, "param object is nil");
	l__assert__1(p5, "param handle is nil");
	if not u2:IsObjectExsit(p4) then
		l__warn__3("object is not exist!" .. l__debug__4.traceback());
		return;
	end;
	p6 = p6 and 0;
	local u9 = { ... };
	local u10 = nil;
	u10 = l__coroutine__5.create(function()
		l__coroutine__5.yield("update_begin");
		local v4 = l__os__6.clock();
		local v5 = 0;
		local v6 = 0;
		while true do
			local v7 = l__os__6.clock();
			local v8 = v7 - v4;
			v4 = v7;
			v5 = v5 + v8;
			v6 = v6 + v8;
			if p6 <= v5 then
				local v9 = nil;
				local v10 = nil;
				v10, v9 = l__xpcall__7(p5, l__debug__4.traceback, p4, v5, v6, l__table__8.unpack(u9));
				v5 = 0;
				if not v10 then
					l__warn__3(v9);
					break;
				end;
				if v9 == true then
					break;
				end;
			end;
			l__coroutine__5.yield("update_step");		
		end;
		p3:DelCo(p4, u10);
	end);
	p3:AddCo(p4, u10);
	return nil;
end;
function v3.AddProcess(p7, p8, p9, ...)
	l__assert__1(p8, "param object is nil");
	l__assert__1(p9, "param handle is nil");
	if not u2:IsObjectExsit(p8) then
		l__warn__3("object is not exist!");
		return;
	end;
	local u11 = { ... };
	local u12 = nil;
	u12 = l__coroutine__5.create(function()
		l__coroutine__5.yield("process_begin");
		local v11, v12 = l__xpcall__7(p9, l__debug__4.traceback, p8, l__table__8.unpack(u11));
		p7:DelCo(p8, u12);
		if not v11 then
			l__warn__3(v12);
		end;
	end);
	p7:AddCo(p8, u12);
	return nil;
end;
function v3.AddCo(p10, p11, p12)
	if not u2:IsObjectExsit(p11) then
		return;
	end;
	p10.co_list[p11] = p10.co_list[p11] or {};
	p10.co_list[p11][p12] = true;
	return p12;
end;
local l__next__13 = next;
function v3.DelCo(p13, p14, p15)
	if p13.co_list[p14] then
		p13.co_list[p14][p15] = nil;
		if not l__next__13(p13.co_list[p14]) then
			p13.co_list[p14] = nil;
		end;
	end;
end;
function v3.CoExsit(p16, p17, p18)
	if not u2:IsObjectExsit(p17) then
		p16.co_list[p17] = nil;
		return;
	end;
	if not p16.co_list[p17] then
		return;
	end;
	return p16.co_list[p17][p18];
end;
function v3.DelObject(p19, p20)
	if not u2:IsObjectExsit(p20) then
		p19.co_list[p20] = nil;
	end;
end;
function v3.AddWaitCo(p21, p22, p23, p24)
	p21.wait_list[p22] = p21.wait_list[p22] or {};
	p21.wait_list[p22][p23] = p24;
end;
function v3.DelWaitCo(p25, p26, p27)
	if p25.wait_list[p26] then
		p25.wait_list[p26][p27] = nil;
		if not l__next__13(p25.wait_list[p26]) then
			p25.wait_list[p26] = nil;
		end;
	end;
end;
function v3.WaitCoExist(p28, p29, p30)
	if not p28.wait_list[p29] then
		return;
	end;
	return p28.wait_list[p29][p30];
end;
local l__pairs__14 = pairs;
function v3.Update(p31)
	for v13, v14 in l__pairs__14(p31.co_list) do
		local v15, v16, v17 = l__pairs__14(v14);
		while true do
			local v18 = nil;
			local v19, v20 = v15(v16, v17);
			if not v19 then
				break;
			end;
			v17 = v19;
			local v21 = nil;
			v21, v18 = l__coroutine__5.resume(v19);
			if not v21 then
				l__warn__3(v18);
				p31:DelCo(v13, v19);
			elseif not p31:CoExsit(v13, v19) then
				p31:DelCo(v13, v19);
			elseif not v18 then
				if l__coroutine__5.status(v19) ~= "dead" then
					l__warn__3("there is roblox yield,update is stop!pls check!\n" .. l__debug__4.traceback(v19));
				end;
				p31:DelCo(v13, v19);
			elseif v18 == "OHOH_update_wait_start" then
				p31:DelCo(v13, v19);
				l__coroutine__5.resume(v19);
			end;		
		end;
	end;
end;
function v3.UpdateCheck(p32)
	return l__next__13(p32.co_list) or l__next__13(p32.wait_list);
end;
return v3;
